package org.pt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.pt.model.Work;

import java.util.List;
import java.util.Map;

public interface WorkMapper extends BaseMapper<Work> {

    @Select("SELECT wt.tags_id, COUNT(wt.tags_id) AS count " +
            "FROM works_tags wt " +
            "JOIN user_possess up ON wt.works_id = up.work_id " +
            "WHERE up.user_id = #{userId} " +
            "GROUP BY wt.tags_id " +
            "ORDER BY count DESC " +
            "LIMIT #{tagsNum}")
    List<Map<String, Object>> findTopTagsByUserId(Integer userId, Integer tagsNum);


}
